home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Resources / Online / Term / Extras / Source / gtlayout-source.lha / LTP_DrawGroup.c < prev    next >
C/C++ Source or Header  |  1996-10-09  |  7KB  |  312 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1996 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14. VOID
  15. LTP_DrawObjectLabel(LayoutHandle *Handle,ObjectNode *Node)
  16. {
  17.     if(Node->Label)
  18.     {
  19.         LONG Left,Top,GlyphHeight = Handle->GlyphHeight;
  20.  
  21.         switch(Node->LabelPlace)
  22.         {
  23.             case PLACE_LEFT:
  24.  
  25.                 Left    = Node->Left;
  26.                 Top        = Node->Top + (Node->Height - GlyphHeight) / 2;
  27.  
  28.                 break;
  29.  
  30.             case PLACE_RIGHT:
  31.  
  32.                 Left    = Node->Left + Node->Width + INTERWIDTH + INTERWIDTH + Node->LabelWidth;
  33.                 Top        = Node->Top + (Node->Height - GlyphHeight) / 2;
  34.  
  35.                 break;
  36.  
  37.             case PLACE_ABOVE:
  38.  
  39.                 Left    = Node->Left + (Node->Width - Node->LabelWidth) / 2 + INTERWIDTH + Node->LabelWidth;
  40.                 Top        = Node->Top - (GlyphHeight + INTERHEIGHT);
  41.  
  42.                 break;
  43.  
  44.             case PLACE_BELOW:
  45.  
  46.                 Left    = Node->Left + (Node->Width - Node->LabelWidth) / 2 + INTERWIDTH + Node->LabelWidth;
  47.                 Top        = Node->Top + Node->Height + INTERHEIGHT;
  48.  
  49.                 break;
  50.         }
  51.  
  52.         LTP_PrintLabel(Handle,Node,Left,Top);
  53.     }
  54. }
  55.  
  56. VOID
  57. LTP_DrawGroup(LayoutHandle *Handle,ObjectNode *Group)
  58. {
  59.     ObjectNode *Node;
  60.     ULONG page;
  61.     LONG i;
  62.  
  63.     if(Group->Label || Group->Special.Group.Frame)
  64.         LTP_DrawGroupLabel(Handle,Group);
  65.  
  66.     SCANPAGE(Group,Node,page)
  67.     {
  68.         switch(Node->Type)
  69.         {
  70.             case BLANK_KIND:
  71.  
  72.                 break;
  73.  
  74. #ifdef OLD_STYLE_DEFAULT_KEY
  75.             case BUTTON_KIND:
  76.  
  77.                 if(Handle->ReturnKey == Node)
  78.                     LTP_DrawBevelBox(Handle,Node);
  79.  
  80.                 break;
  81. #endif
  82. #ifdef DO_GAUGE_KIND
  83.             case GAUGE_KIND:
  84.             {
  85.                 LONG Percent = Node->Current;
  86.  
  87.                 Node->Current = 0;
  88.  
  89.                 LTP_DrawGauge(Handle,Node,Percent,TRUE);
  90.  
  91.                 break;
  92.             }
  93. #endif
  94.             case PALETTE_KIND:
  95.  
  96.                 if(Node->Special.Palette.UsePicker)
  97.                     LTP_DrawPalette(Handle,Node);
  98.  
  99.                 break;
  100.  
  101.             case GROUP_KIND:
  102.  
  103.                 if(Node->Label)
  104.                     LTP_DrawGroupLabel(Handle,Node);
  105.  
  106.                 LTP_DrawGroup(Handle,Node);
  107.  
  108.                 break;
  109.  
  110.             case XBAR_KIND:
  111.             {
  112.                 LONG Top = Node->Top + ((Node->Height + 1) / 2) - 1;
  113.                 struct RastPort *RPort = &Handle->RPort;
  114.  
  115.                 if(Node->Special.Bar.FullSize)
  116.                 {
  117.                     LTP_SetAPen(RPort,Handle->ShadowPen);
  118.                     LTP_DrawLine(RPort,Handle->Window->BorderLeft,Top,Handle->Window->Width - (Handle->Window->BorderRight + 1),Top);
  119.  
  120.                     LTP_SetAPen(RPort,Handle->ShinePen);
  121.                     LTP_DrawLine(RPort,Handle->Window->BorderLeft,Top + 1,Handle->Window->Width - (Handle->Window->BorderRight + 1),Top + 1);
  122.                 }
  123.                 else
  124.                 {
  125.                     LONG Room;
  126.  
  127.                     if(Node->Special.Bar.Parent->Label)
  128.                         Room = 2 * Handle->GlyphWidth;
  129.                     else
  130.                         Room = 0;
  131.  
  132.                     LTP_SetAPen(RPort,Handle->ShadowPen);
  133.                     LTP_PolyDraw(RPort,3,
  134.                         Node->Special.Bar.Parent->Left + Room,Top + 1,
  135.                         Node->Special.Bar.Parent->Left + Room,Top,
  136.                         Node->Special.Bar.Parent->Left + Node->Special.Bar.Parent->Width - 1 - 1 - Room,Top);
  137.  
  138.                     LTP_SetAPen(RPort,Handle->ShinePen);
  139.                     LTP_PolyDraw(RPort,3,
  140.                         Node->Special.Bar.Parent->Left + Room + 1,Top + 1,
  141.                         Node->Special.Bar.Parent->Left + Node->Special.Bar.Parent->Width - 1 - Room,Top + 1,
  142.                         Node->Special.Bar.Parent->Left + Node->Special.Bar.Parent->Width - 1 - Room,Top);
  143.                 }
  144.  
  145.                 break;
  146.             }
  147.  
  148.             case YBAR_KIND:
  149.             {
  150.                 LONG Left = Node->Left + ((Node->Width + 1) / 2) - 1,Room;
  151.                 struct RastPort *RPort = &Handle->RPort;
  152.  
  153.                 if(Node->Special.Bar.Parent->Label)
  154.                     Room = Handle->GlyphHeight + Handle->InterHeight;
  155.                 else
  156.                     Room = 0;
  157.  
  158.                 LTP_SetAPen(RPort,Handle->ShadowPen);
  159.                 LTP_PolyDraw(RPort,3,
  160.                     Left + 1,    Node->Special.Bar.Parent->Top + Room,
  161.                     Left,        Node->Special.Bar.Parent->Top + Room,
  162.                     Left,        Node->Special.Bar.Parent->Top + Node->Special.Bar.Parent->Height - 1 - 1 - Room);
  163.  
  164.                 LTP_SetAPen(RPort,Handle->ShinePen);
  165.                 LTP_PolyDraw(RPort,3,
  166.                     Left + 1,    Node->Special.Bar.Parent->Top + Room + 1,
  167.                     Left + 1,    Node->Special.Bar.Parent->Top + Node->Special.Bar.Parent->Height - 1 - Room,
  168.                     Left,        Node->Special.Bar.Parent->Top + Node->Special.Bar.Parent->Height - 1 - Room);
  169.  
  170.                 if((Handle->AspectY + Handle->AspectX - 1) / Handle->AspectX >= 2)
  171.                 {
  172.                     LTP_SetAPen(RPort,Handle->ShadowPen);
  173.                     LTP_DrawLine(RPort,    Left - 1,    Node->Special.Bar.Parent->Top + Room,
  174.                                 Left - 1,    Node->Special.Bar.Parent->Top + Node->Special.Bar.Parent->Height - 1 - Room);
  175.  
  176.                     LTP_SetAPen(RPort,Handle->ShinePen);
  177.                     LTP_DrawLine(RPort,    Left + 2,    Node->Special.Bar.Parent->Top + Room,
  178.                                 Left + 2,    Node->Special.Bar.Parent->Top + Node->Special.Bar.Parent->Height - 1 - Room);
  179.                 }
  180.  
  181.                 break;
  182.             }
  183.  
  184.             case FRAME_KIND:
  185.  
  186.                 if(Node->Special.Frame.DrawBox)
  187.                     LTP_DrawBevelBox(Handle,Node);
  188.  
  189.                 if(Node->Special.Frame.RefreshHook)
  190.                 {
  191.                     RefreshMsg Message;
  192.  
  193.                     Message.ID        = Node->ID;
  194.                     Message.Left    = Node->Left;
  195.                     Message.Top        = Node->Top;
  196.                     Message.Width    = Node->Width;
  197.                     Message.Height    = Node->Height;
  198.  
  199.                     if(Node->Special.Frame.DrawBox)
  200.                     {
  201.                         Message.Left    += 4;
  202.                         Message.Top        += 2;
  203.                         Message.Width    -= 8;
  204.                         Message.Height    -= 4;
  205.                     }
  206.  
  207.                     CallHookPkt(Node->Special.Frame.RefreshHook,Handle,&Message);
  208.                 }
  209.  
  210.                 // FALL THROUGH TO...
  211.  
  212.             case BOOPSI_KIND:
  213.  
  214.                 // FALL THROUGH TO...
  215.  
  216.             case POPUP_KIND:
  217.  
  218.                 // FALL THROUGH TO...
  219.  
  220.             case TAPEDECK_KIND:
  221.  
  222.                 LTP_DrawObjectLabel(Handle,Node);
  223.                 break;
  224.  
  225.             case MX_KIND:
  226.  
  227.                 if(Node->Label && !V39)
  228.                     LTP_PrintLabel(Handle,Node,Node->Left,Node->Top + (Node->Height - Handle->GlyphHeight) / 2 + 1);
  229.  
  230.                 break;
  231.  
  232.             case LISTVIEW_KIND:
  233.             {
  234.                 struct RastPort *RPort = &Handle->RPort;
  235.  
  236.                 if(Node->Special.List.ExtraLabels)
  237.                 {
  238.                     LTP_SetPens(RPort,Handle->TextPen,0,JAM1);
  239.  
  240.                     for(i = 0 ; Node->Special.List.ExtraLabels[i] ; i++)
  241.                     {
  242.                         LONG Len = strlen(Node->Special.List.ExtraLabels[i]);
  243.  
  244.                         LTP_PrintText(RPort,Node->Special.List.ExtraLabels[i],Len,Node->Left - (TextLength(RPort,Node->Special.List.ExtraLabels[i],Len) + INTERWIDTH),Node->Top + 2 + i * Handle->GlyphHeight);
  245.                     }
  246.                 }
  247.  
  248.                 if(Node->Label)
  249.                 {
  250.                     if(Node->LabelPlace == PLACE_ABOVE && Node->Special.List.FlushLabelLeft)
  251.                     {
  252.                         struct TextFont *Font = NULL,*OldFont;
  253.  
  254.                         if(Node->Special.List.TextAttr)
  255.                         {
  256.                             if(Font = LTP_OpenFont(Node->Special.List.TextAttr))
  257.                             {
  258.                                 OldFont = RPort->Font;
  259.  
  260.                                 SetFont(RPort,Font);
  261.                             }
  262.                             else
  263.                                 break;
  264.                         }
  265.  
  266.                         LTP_PrintLabel(Handle,Node,Node->Left + 2 + INTERWIDTH + Node->LabelWidth,Node->Top - (Handle->GlyphHeight + INTERHEIGHT));
  267.  
  268.                         if(Font)
  269.                         {
  270.                             SetFont(RPort,OldFont);
  271.  
  272.                             CloseFont(Font);
  273.                         }
  274.                     }
  275.                     else
  276.                     {
  277.                         if(Node->Special.List.TextAttr)
  278.                             LTP_DrawObjectLabel(Handle,Node);
  279.                     }
  280.                 }
  281.  
  282.                 break;
  283.             }
  284.  
  285.             case BOX_KIND:
  286.             {
  287.                 struct RastPort *RPort = &Handle->RPort;
  288.  
  289.                 Node->Special.Box.Parent = Group;
  290.  
  291.                 if(Node->Special.Box.DrawBox)
  292.                     LTP_DrawBevelBox(Handle,Node);
  293.  
  294.                 for(i = 0 ; i < Node->Lines ; i++)
  295.                 {
  296.                     if(Node->Special.Box.Labels && Node->Special.Box.Labels[i])
  297.                     {
  298.                         LONG Len = strlen(Node->Special.Box.Labels[i]);
  299.  
  300.                         LTP_SetPens(RPort,Handle->TextPen,0,JAM1);
  301.                         LTP_PrintText(RPort,Node->Special.Box.Labels[i],Len,Node->Left - (TextLength(RPort,Node->Special.Box.Labels[i],Len) + INTERWIDTH),Node->Top + 2 + i * Handle->GlyphHeight);
  302.                     }
  303.  
  304.                     LTP_PrintBoxLine(Handle,Node,i);
  305.                 }
  306.  
  307.                 break;
  308.             }
  309.         }
  310.     }
  311. }
  312.